//
//  ACEMeUpdatePSDController.m
//  ACE
//
//  Created by zhangtao on 2018/8/13.
//  Copyright © 2018年 zt.td. All rights reserved.
//

#import "ACEMeUpdatePSDController.h"
#import "ACEMeChangePSDCell.h"
@interface ACEMeUpdatePSDController ()

@end

@implementation ACEMeUpdatePSDController
{
    NSArray *titles;
    NSArray *placeholder;
    UIButton *submitBtn;
}

-(UIButton *)submitBtn{
    if (!submitBtn) {
        submitBtn = [[UIButton alloc]init];
        [submitBtn setTitle:@"确定" forState:UIControlStateNormal];
        if ([ACEPublicTool currentRoleIsStudent]) {
            [submitBtn setBackgroundColor:deepGreen];
        }else{
            [submitBtn setBackgroundColor:teacher_main_color];
        }
    }
    return submitBtn;
}

- (void)viewDidLoad {
    [super viewDidLoad];
    self.title = @"修改密码";
    titles = @[@"邮箱",@"验证码",@"旧密码",@"新密码"];
    placeholder = @[@"请输入邮箱",@"请输入验证码",@"请输入旧密码",@"请输入新密码"];
    [self.tableView registerNib:[UINib nibWithNibName:@"ACEMeChangePSDCell" bundle:nil] forCellReuseIdentifier:@"cell"];

}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

-(NSInteger)numberOfSectionsInTableView:(UITableView *)tableView{
    return 1;
}

-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
    return 4;
}

-(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
    return 50;
}

-(CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section{
    return 100;
}

-(CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section{
    return 15;
}


-(UIView *)tableView:(UITableView *)tableView viewForFooterInSection:(NSInteger)section{
    UIView *view = [[UIView alloc]initWithFrame:CGRectMake(0, 0, ACEWidth, 100)];
    view.backgroundColor = [UIColor clearColor];
    self.submitBtn.frame = CGRectMake(ACEWidth/2-150, 50, 300, 50);
    self.submitBtn.layer.cornerRadius = 25;
    self.submitBtn.layer.masksToBounds = YES;
    [view addSubview:self.submitBtn];
    return view;
}


- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
    ACEMeChangePSDCell *cell = [tableView dequeueReusableCellWithIdentifier:@"cell"];
    cell.titleLab.text = titles[indexPath.row];
    cell.TF.placeholder = placeholder[indexPath.row];
    if (indexPath.row == 1) {
        cell.getCodeBtn.hidden = NO;
        [cell.getCodeBtn setTitleColor:MAIN_COLOR() forState:UIControlStateNormal];
    }
    // Configure the cell...
    
    return cell;
}


/*
// Override to support conditional editing of the table view.
- (BOOL)tableView:(UITableView *)tableView canEditRowAtIndexPath:(NSIndexPath *)indexPath {
    // Return NO if you do not want the specified item to be editable.
    return YES;
}
*/

/*
// Override to support editing the table view.
- (void)tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath {
    if (editingStyle == UITableViewCellEditingStyleDelete) {
        // Delete the row from the data source
        [tableView deleteRowsAtIndexPaths:@[indexPath] withRowAnimation:UITableViewRowAnimationFade];
    } else if (editingStyle == UITableViewCellEditingStyleInsert) {
        // Create a new instance of the appropriate class, insert it into the array, and add a new row to the table view
    }   
}
*/

/*
// Override to support rearranging the table view.
- (void)tableView:(UITableView *)tableView moveRowAtIndexPath:(NSIndexPath *)fromIndexPath toIndexPath:(NSIndexPath *)toIndexPath {
}
*/

/*
// Override to support conditional rearranging of the table view.
- (BOOL)tableView:(UITableView *)tableView canMoveRowAtIndexPath:(NSIndexPath *)indexPath {
    // Return NO if you do not want the item to be re-orderable.
    return YES;
}
*/

/*
#pragma mark - Table view delegate

// In a xib-based application, navigation from a table can be handled in -tableView:didSelectRowAtIndexPath:
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
    // Navigation logic may go here, for example:
    // Create the next view controller.
    <#DetailViewController#> *detailViewController = [[<#DetailViewController#> alloc] initWithNibName:<#@"Nib name"#> bundle:nil];
    
    // Pass the selected object to the new view controller.
    
    // Push the view controller.
    [self.navigationController pushViewController:detailViewController animated:YES];
}
*/

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
